package com.navi;

import com.rabbitmq.client.ConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by admin on 2017/6/20.
 */
@Configuration
public class RabbitMQConfiguration {

    @Bean(name = "factory")
    public ConnectionFactory factory(@Value("${spring.rabbitmq.host}") String hostName,
                                     @Value("${spring.rabbitmq.port}") int portNumber,
                                     @Value("${spring.rabbitmq.username}") String username,
                                     @Value("${spring.rabbitmq.password}") String password) {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost(hostName);
        factory.setPort(portNumber);
//        factory.setVirtualHost("/");
        factory.setUsername(username);
        factory.setPassword(password);
        return factory;

    }


}
